# -*-coding:utf-8-*-
import sys
import time


class AddCookie(object):

    def __init__(self, obj=None):
        self.obj = obj
        if not obj:
            print("{}:dirver_obj为空".format(sys.argv[0]))

    def add_cookie(self):
        self.obj.get_element(*("id", "name")).send_keys("gdsa")
        self.obj.get_element(*("id", "pwd")).send_keys("admin")
        time.sleep(3)
        self.obj.get_element(*("id", "submit")).click()
        cookies = self.obj.dirver.get_cookies()
        name = cookies[0]["name"]
        value = cookies[0]["value"]
        self.obj.dirver.add_cookie({"name": name, "value": value})
